﻿<UserControl x:Class="QuanLyKho.ucTienNo"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
             xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" 
             xmlns:local="clr-namespace:QuanLyKho.CommonControl"
             >
    <UserControl.Resources>
        <Style x:Key="customContentStyleNgayTra" TargetType="{x:Type ContentPresenter}">
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <TextBlock Text="Ngày trả" FontWeight="Bold" Foreground="Red"></TextBlock>
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="customContentStyleNhapNo" TargetType="{x:Type ContentPresenter}">
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <TextBlock Text="Nhập nợ" FontWeight="Bold" Foreground="Red"></TextBlock>
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="70"></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="42"></RowDefinition>
        </Grid.RowDefinitions>
        
        <GroupBox Grid.Row="0" Header="Tìm kiếm" Margin="2 2 2 2">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"></ColumnDefinition>
                    <ColumnDefinition Width="100*"></ColumnDefinition>
                    <ColumnDefinition Width="60"></ColumnDefinition>
                    <ColumnDefinition Width="100*"></ColumnDefinition>
                    <ColumnDefinition Width="60"></ColumnDefinition>
                    <ColumnDefinition Width="100*"></ColumnDefinition>
                    <ColumnDefinition Width="80"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                
                <TextBlock Text="Phương thức:" Grid.Column="0" Grid.Row="0" Margin="2 2 2 2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <dxe:ComboBoxEdit Name="cboPhuongThuc" 
                          IsTextEditable="True" Margin="2 2 2 2"
                          VerticalAlignment="Center"
                          Grid.Column="1" Grid.Row="1"
                          AutoComplete="True"
                          IsCaseSensitiveSearch="False" 
                          InvalidValueBehavior="AllowLeaveEditor" 
                          KeyboardNavigation.TabIndex="0"
                         />

                <TextBlock Text="Từ ngày:" Grid.Column="2" Grid.Row="0" Margin="2 2 2 2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <dxe:DateEdit Grid.Column="3" Margin="2 2 2 2" Grid.Row="0" x:Name="dateEditTuNgay" KeyboardNavigation.TabIndex="0" VerticalAlignment="Center" Mask="dd/MM/yyyy"
                                  MaskAutoComplete="Optimistic" MaskCulture="vi-VN" MaskType="DateTimeAdvancingCaret" DisplayFormatString="dd/MM/yyyy" CausesValidation="False"/>
                                
                <TextBlock Text="Đến ngày:" Grid.Column="4" Grid.Row="0" Margin="2 2 2 2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <dxe:DateEdit Grid.Column="5" Margin="2 2 2 2" Grid.Row="0" x:Name="dateEditDenNgay" KeyboardNavigation.TabIndex="0" VerticalAlignment="Center" Mask="dd/MM/yyyy"
                                  MaskAutoComplete="Optimistic" MaskCulture="vi-VN" MaskType="DateTimeAdvancingCaret" DisplayFormatString="dd/MM/yyyy" CausesValidation="False"/>

                <Button x:Name="btnTimTen" ToolTip="Tìm kiếm theo ngày nhập" Content="Tìm" Grid.Column="6" Width="70" Grid.Row="0" VerticalAlignment="Center" Margin="2 2 2 2" Cursor="Hand" HorizontalContentAlignment="Right" Click="btnTimTen_Click">
                    <Button.Template>
                        <ControlTemplate>
                           <Image HorizontalAlignment="Left" Source="/QuanLyKho;component/Images/Icons/zoom-32x32.png" Height="25" Width="32"></Image>
                        </ControlTemplate>
                        
                    </Button.Template>
                </Button>


            </Grid>
        </GroupBox>

        <Grid Grid.Row="1" Margin="2 2 2 2" Name="expGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="100*"></RowDefinition>
                <RowDefinition Height="100*"></RowDefinition>
            </Grid.RowDefinitions>
            
            <dxg:GridControl Name="gridDsTienNo" Height="auto" Grid.Row="0" Margin="2 2 2 2" ToolTip="Dòng đầu tiên của danh sách hỗ trợ tìm kiếm">
                
                <dxg:GridControl.Columns>

                <dxg:GridColumn Name="cluSTT" Header="STT" Width="50" AllowEditing="False">
                    <dxg:GridColumn.DisplayTemplate>
                        <ControlTemplate>
                            <dxe:TextEdit x:Name="thayDoiSTT" Text="{Binding Path =Data.RowHandle.Value,Converter ={local:RowHandleToStringConverter},Mode =OneWay}" HorizontalAlignment="Center" EditMode="InplaceActive" />                           
                        </ControlTemplate>
                    </dxg:GridColumn.DisplayTemplate>
                </dxg:GridColumn>
                    <dxg:GridColumn Header="Phiếu nhập" Width="50" FieldName="PhieuNhapThuoc.IdPhieuNhap" />
                    <dxg:GridColumn Header="Mã NPP" Width="100" MinWidth="50" FieldName="PhieuNhapThuoc.MaNhaPhanPhoi"/>
                    <dxg:GridColumn Header="Tên NPP" Width="150" FieldName="DmNhaPhanPhoi.TenNhaPhanPhoi"/>
                    <dxg:GridColumn Header="Địa chỉ" Width="50" FieldName="DmNhaPhanPhoi.DiaChi" AllowEditing="True">
                        <dxg:GridColumn.EditSettings>
                            <dxe:MemoEditSettings ShowIcon="True" PopupWidth="250" MemoTextWrapping="Wrap" MemoVerticalScrollBarVisibility="Auto"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Số hóa đơn" Width="50" FieldName="PhieuNhapThuoc.SoHoaDon"/>
                    <dxg:GridColumn Header="Số tiền" Width="100" FieldName="SoTien">
                        <dxg:GridColumn.EditSettings >
                            <dxe:TextEditSettings Mask="c0" MaskType="Numeric" MaskUseAsDisplayFormat="True" MaskCulture="Vietnamese (Vietnam)"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Ngày nhập" Width="50" FieldName="PhieuNhapThuoc.NgayNhap">
                        <dxg:GridColumn.EditSettings>
                            <dxe:DateEditSettings Mask="dd/MM/yyyy" MaskAutoComplete="Optimistic" MaskCulture="vi-VN" MaskType="DateTimeAdvancingCaret" DisplayFormat="dd/MM/yyyy"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Ngày trả" Width="50" FieldName="NgayTra" 
                                    x:Name="columnNgayTra" AllowEditing="True" Validate="GridColumn_Validate"
                                    ColumnHeaderContentStyle="{StaticResource customContentStyleNgayTra}">
                        <dxg:GridColumn.EditSettings>
                            <dxe:DateEditSettings Mask="dd/MM/yyyy" MaskAutoComplete="Optimistic" MaskCulture="vi-VN" MaskType="DateTimeAdvancingCaret" DisplayFormat="dd/MM/yyyy"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Lý do nợ" Width="50" FieldName="LyDo" AllowEditing="True">
                        <dxg:GridColumn.EditSettings>
                            <dxe:MemoEditSettings ShowIcon="True" PopupWidth="250" MemoTextWrapping="Wrap" MemoVerticalScrollBarVisibility="Auto"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Nhập nợ" Width="50" AllowEditing="False" x:Name="columChkNhapNo" ColumnHeaderContentStyle="{StaticResource customContentStyleNhapNo}">
                        <dxg:GridColumn.DisplayTemplate>
                            <ControlTemplate>
                                <dxe:CheckEdit HorizontalAlignment="Center" IsChecked="False" Checked="CheckEdit_Checked" Unchecked="CheckEdit_Unchecked"/>
                            </ControlTemplate>
                        </dxg:GridColumn.DisplayTemplate>
                    </dxg:GridColumn>
                </dxg:GridControl.Columns>
                <dxg:GridControl.TotalSummary>
                    <dxg:GridSummaryItem FieldName="SoTien"  SummaryType="Sum" ShowInColumn="SoTien" DisplayFormat="Tổng: {0:N0}">
                    </dxg:GridSummaryItem>
                </dxg:GridControl.TotalSummary>
                <dxg:GridControl.View>
                    <dxg:TableView Name="viewgridDsTienNo" AutoWidth="true" ShowGroupPanel="False" AllowEditing="False"
                        MouseDoubleClick="view_MouseDoubleClick" KeyUp="view_KeyUp"
                        ShowAutoFilterRow="True" 
                        ShowGroupedColumns="False" 
                        ShowColumnHeaders="True"   
                        AllowDrop="False"
                        AllowGrouping="False" 
                        AllowMoveColumnToDropArea="False" 
                        AllowMoving="False" 
                        KeyboardNavigation.TabIndex="0"
                        IsColumnMenuEnabled="False"    
                        IsGroupPanelMenuEnabled="False" 
                        IsRowCellMenuEnabled="False" 
                        IsTotalSummaryMenuEnabled="False" 
                        AllowHorizontalScrollingVirtualization="True"
                        ShowTotalSummary="True" 
                        MaxWidth="1800" CellValueChanging="viewgridDsTienNo_CellValueChanging" />
        </dxg:GridControl.View>
                
        </dxg:GridControl>
           
            <dxg:GridControl Name="gridDsChiTietTienNoVatTu" Grid.Row="1" Margin="2 2 2 2" ToolTip="Dòng đầu tiên của danh sách hỗ trợ tìm kiếm">
                <dxg:GridControl.Columns>

                    <dxg:GridColumn Name="cluSTTVatTu" Header="STT" Width="50" AllowEditing="False">
                        <dxg:GridColumn.DisplayTemplate>
                            <ControlTemplate>
                                <dxe:TextEdit x:Name="thayDoiSTTVatTu" Text="{Binding Path =Data.RowHandle.Value,Converter ={local:RowHandleToStringConverter},Mode =OneWay}" HorizontalAlignment="Center" EditMode="InplaceActive" />
                            </ControlTemplate>
                        </dxg:GridColumn.DisplayTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Mã thuốc" Width="100" MinWidth="50" FieldName="MaThuoc" />
                    <dxg:GridColumn Header="Tên thuốc" Width="150" MinWidth="50" FieldName="Dm_Thuoc.TenThuoc"/>
                    <dxg:GridColumn Header="Số lượng" Width="50" FieldName="SoLuong">
                        <dxg:GridColumn.EditSettings >
                            <dxe:TextEditSettings Mask="N0" MaskType="Numeric" MaskUseAsDisplayFormat="True"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Hạn dùng" Width="50" FieldName="HanDung">
                        <dxg:GridColumn.EditSettings>
                            <dxe:DateEditSettings Mask="dd/MM/yyyy" MaskAutoComplete="Optimistic" MaskCulture="vi-VN" MaskType="DateTimeAdvancingCaret" DisplayFormat="dd/MM/yyyy"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Giá nhập" Width="50" FieldName="GiaNhap">
                        <dxg:GridColumn.EditSettings >
                            <dxe:TextEditSettings Mask="c0" MaskType="Numeric" MaskUseAsDisplayFormat="True" MaskCulture="Vietnamese (Vietnam)"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Giá xuất" Width="50" FieldName="GiaXuat">
                        <dxg:GridColumn.EditSettings >
                            <dxe:TextEditSettings Mask="c0" MaskType="Numeric" MaskUseAsDisplayFormat="True" MaskCulture="Vietnamese (Vietnam)"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Số lô" Width="50" FieldName="SoLo">
                        <dxg:GridColumn.EditSettings >
                            <dxe:TextEditSettings Mask="N0" MaskType="Numeric" MaskUseAsDisplayFormat="True"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                </dxg:GridControl.Columns>
                <dxg:GridControl.View>
                    <dxg:TableView Name="viewgridDsChiTietTienNoVatTu" AutoWidth="true" ShowGroupPanel="False" AllowEditing="False"
                        ShowAutoFilterRow="True" 
                        ShowGroupedColumns="False" 
                        ShowColumnHeaders="True"   
                        AllowDrop="False"
                        AllowGrouping="False" 
                        AllowMoveColumnToDropArea="False" 
                        AllowMoving="False" 
                        KeyboardNavigation.TabIndex="0"
                        IsColumnMenuEnabled="False"    
                        IsGroupPanelMenuEnabled="False" 
                        IsRowCellMenuEnabled="False" 
                        IsTotalSummaryMenuEnabled="False" 
                        AllowHorizontalScrollingVirtualization="True"
                        MaxWidth="1800"
                           />
                </dxg:GridControl.View>
            </dxg:GridControl>
            
        </Grid>
        
        
        <dxb:BarManager Name="barManagerButton" Grid.Row="2" CreateStandardLayout="True">
            <dxb:BarManager.Items>
                <!--Regular bar items-->
                <dxb:BarButtonItem x:Name="btnLuu" Content="_Lưu" BarItemDisplayMode="ContentAndGlyph"  
                                   LargeGlyph ="/Images/Icons/save.png" ItemClick="btnLuu_ItemClick" />
                <dxb:BarButtonItem x:Name="btnXoa" Content="_Xóa" BarItemDisplayMode="ContentAndGlyph" 
                                   LargeGlyph ="/Images/Icons/deletered.png" ItemClick="btnXoa_ItemClick" />
                <dxb:BarButtonItem x:Name="btnHuyBo" Content="_Hủy bỏ" BarItemDisplayMode="ContentAndGlyph" 
                                   LargeGlyph ="/Images/Icons/undo.png" ItemClick="btnHuyBo_ItemClick" />
                <dxb:BarButtonItem x:Name="btnDong" Content="Đó_ng" BarItemDisplayMode="ContentAndGlyph" 
                                   LargeGlyph ="/Images/Icons/logout.png" ItemClick="btnDong_ItemClick" />
            </dxb:BarManager.Items>
            <!--Create two bars-->
            <dxb:BarManager.Bars>
                <dxb:Bar>
                    <dxb:Bar.ItemLinks>
                        <dxb:BarItemLink BarItemName="btnLuu"/>
                        <!--<dxb:BarItemLink BarItemName="btnXoa"/>-->
                        <dxb:BarItemLink BarItemName="btnHuyBo"/>
                        <dxb:BarItemLink BarItemName="btnDong"/>
                    </dxb:Bar.ItemLinks>
                </dxb:Bar>
            </dxb:BarManager.Bars>
        </dxb:BarManager>
    </Grid>
</UserControl>
